import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { UserNoticeVO, UserNoticeForm, UserNoticeQuery } from "@/api/system/userNotice/types";

/**
 * 查询当前用户未读通知数量
 *
 * @param {object} query
 */
export const myNoticeCount = (): AxiosPromise<number> => {
	return request({
		url: "/system/userNotice/getMyNoticeCount",
		method: "get",
	});
};

/**
 * 查询当前用户未读通知列表
 *
 */
export const myNoticeList = (): AxiosPromise<UserNoticeVO[]> => {
	return request({
		url: "/system/userNotice/getMyNoticeList",
		method: "get",
	});
};

/**
 * 查询用户消息关联列表
 *
 * @param {object} query
 */
export const listNotice = (query?: UserNoticeQuery): AxiosPromise<UserNoticeVO[]> => {
	return request({
		url: "/system/userNotice/list",
		method: "get",
		params: query,
	});
};

/**
 * 查询用户消息关联详细
 *
 * @param {string} id
 */
export const getNotice = (id: string | number): AxiosPromise<UserNoticeVO> => {
	return request({
		url: "/system/userNotice/" + id,
		method: "get",
	});
};

/**
 * 新增用户消息关联
 *
 * @param {object} data
 */
export const addNotice = (data: UserNoticeForm) => {
	return request({
		url: "/system/userNotice/add",
		method: "post",
		data: data,
	});
};

/**
 *  修改用户消息关联
 *
 * @param {object} data
 */
export const updateNotice = (data: UserNoticeForm) => {
	return request({
		url: "/system/userNotice/edit",
		method: "put",
		data: data,
	});
};

/**
 * 删除用户消息关联
 *
 * @param {string} id
 */
export const delNotice = (id: string | number | Array<string | number>) => {
	return request({
		url: "/system/userNotice/" + id,
		method: "delete",
	});
};

